// 用户操作的功能
import request from '@/utils/request'
// import store from '@/store/index.js'

// 用户登录
export function login (user) {
  return request({
    method: 'POST',
    url: '/app/v1_0/authorizations',
    data: user
  })
}

// 获取个人信息
export function getProfile () {
  return request({
    method: 'GET',
    url: '/app/v1_0/user/profile'
  })
}

// 获取用户信息
export function getInfo () {
  return request({
    method: 'GET',
    url: '/app/v1_0/user'
  })
}

/**
 * 编辑用户个人资料
 * @param {*} data
 */
export function updateUserInfo (data) {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/profile',
    data
  })
}

/**
 * 更新头像
 * @param {*} fromData
 */
export function updateUserPhoto (fromData) {
  return request({
    method: 'PATCH',
    url: '/app/v1_0/user/photo',
    data: fromData
  })
}

/**
 * 关注用户
 * @param {*} autId 作者id
 */
export function followUser (autId) {
  return request({
    mothod: 'POST',
    url: '/app/v1_0/user/followings',
    data: {
      target: autId
    }
  })
}

/**
 * 取消关注用户
 * @param {*} autId 作者id
 */
export function unFollowUser (autId) {
  return request({
    method: 'DELETE',
    url: '/app/v1_0/user/followings/' + autId
  })
}
